'''
Created on Aug 25, 2011

@author: david
'''

from app.GHT.actions import GHTAction

class Fetch(GHTAction):
    """
    Fetch all videos
    """
    def execute(self):
        req = self.request
        import json
        
        vendor = req.getParameter('vendor')
        
        array = []
        
        try:
            from app.GHT.agents.videos.videoagent import VideoAgent
            agent = VideoAgent()
            array = agent.loadAllVideosByVendor(vendor)
        except Exception,ex:
            from pspy import Notification
            n = Notification("Error loading videos")
            n.setException(ex)
                
        return self.JSONOutput(json.dumps(array))
    
    def sess_check(self):
        return True